Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the cyclocomp namespace check into the factory #2785

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

MichaelChirico
Copy link
Collaborator

Closes #2777

Two notable changes accompany this:

  • Rather than error up-front if {cyclocomp} is unavailable, we warn & return a "dumb" linter that just always & immediately finds no lints.
  • linters_with_tags() (via call_linter_factory()) warns instead of errors when a linter fails to build. Again we return the "dumb" linter in this case. This is not strictly needed thanks to only warning from the factory, but I think it's a better design anyway.

Mostly in tests I've opted anyway for skip()s, rather than an awkward construct where we optionally expect_warning(), or swap between expect_warning()/expect_no_warning(), or ...

This exercise also flushed out some more tests that are implicitly reading our main project .lintr file, fixing which increases their hermeticity.

@AshesITR
Copy link
Collaborator

Warnings are easy to overlook - not the biggest fan of this approach.
Maybe warn in the constructor but still error out in the implementation?

Co-authored-by: AshesITR <alexander.rosenstock@web.de>
Copy link

codecov bot commented Feb 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.58%. Comparing base (675b9cd) to head (d0a3768).
Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2785      +/-   ##
==========================================
+ Coverage   99.57%   99.58%   +0.01%     
==========================================
  Files         125      125              
  Lines        6840     6829      -11     
==========================================
- Hits         6811     6801      -10     
+ Misses         29       28       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

R/with.R Outdated
@@ -187,10 +187,11 @@ call_linter_factory <- function(linter_factory, linter_name, package) {
linter <- tryCatch(
linter_factory(),
error = function(e) {
cli_abort(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should return a "disabled" linter here too? Probably I'm overthinking it. Reverting for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move requireNamespace() check for cyclocomp_linter() to the factory?
2 participants